#ifndef MYDATA_H
#define MYDATA_H

#include <QObject>

class MyData : public QObject
{
    Q_OBJECT
public:
    explicit MyData(QObject *parent = nullptr);
    //初始化服务器
    void InitServer();
    Q_PROPERTY(int wd READ getWd WRITE setWd NOTIFY dataChanged)
    Q_PROPERTY(int sd READ getSd WRITE setSd NOTIFY dataChanged)
    Q_PROPERTY(int gz READ getGz WRITE setGz NOTIFY dataChanged)
    Q_PROPERTY(int qt READ getQt WRITE setQt NOTIFY dataChanged)

    Q_PROPERTY(int wd_on_off READ getWd_on_off WRITE setWd_on_off NOTIFY wonoffChanged)
    Q_PROPERTY(int sd_on_off READ getSd_on_off WRITE setSd_on_off NOTIFY sonoffChanged)
    Q_PROPERTY(int gz_on_off READ getGz_on_off WRITE setGz_on_off NOTIFY gonoffChanged)
    Q_PROPERTY(int qt_on_off READ getQt_on_off WRITE setQt_on_off NOTIFY qonoffChanged)

    Q_PROPERTY(int _client READ getClient WRITE setClient NOTIFY wlChanged)
    Q_PROPERTY(int znkz READ getZnkz WRITE setZnkz NOTIFY znChanged)

    Q_PROPERTY(int myinit READ getMyinit WRITE setMyinit NOTIFY initChanged)

    Q_INVOKABLE int my_send(int com, int a, int b, int c, int d, int e=-1, int f=-1, int g=-1, int h=-1);
    Q_INVOKABLE void myclose();
    Q_INVOKABLE void myaccept();
    Q_INVOKABLE void myexit();

    pthread_t thread;

    int _listen_sock;
    int _client;
    int _port;

    int znkz;

    int myinit;

    int wd;
    int sd;
    int gz;
    int qt;

    int wd_on_off;
    int sd_on_off;
    int gz_on_off;
    int qt_on_off;

    int getWd() const;
    void setWd(int value);

    int getSd() const;
    void setSd(int value);

    int getGz() const;
    void setGz(int value);

    int getQt() const;
    void setQt(int value);

    int getWd_on_off() const;
    void setWd_on_off(int value);

    int getSd_on_off() const;
    void setSd_on_off(int value);

    int getGz_on_off() const;
    void setGz_on_off(int value);

    int getQt_on_off() const;
    void setQt_on_off(int value);

    int getClient() const;
    void setClient(int client);

    int getZnkz() const;
    void setZnkz(int value);

    int getMyinit() const;
    void setMyinit(int value);

signals:
    Q_INVOKABLE void dataChanged();

    Q_INVOKABLE void wonoffChanged();
    Q_INVOKABLE void sonoffChanged();
    Q_INVOKABLE void gonoffChanged();
    Q_INVOKABLE void qonoffChanged();

    Q_INVOKABLE void wlChanged();
    Q_INVOKABLE void znChanged();
    Q_INVOKABLE void initChanged();
};

#endif // MYDATA_H
